﻿@{
    var path = ViewData["path"] as string;    
    
    <p id="repositoryAddress">
        @Html.ActionLink(Resources.Repository_AddressBar_Root, "Tree", new { id = ViewBag.ID, name = ViewData["currentBranch"] ?? ViewData["name"], path = ""})
        @if (path != null)
        {
            <text>/</text>
            var dirs = path.Split('/');
            for (int i = 0; i < dirs.Length; i++)
            {
                string currentPath = string.Empty;
                for (int j = 0; j < i; j++)
                {
                    currentPath += dirs[j] + "/";
                }
                currentPath += dirs[i];

                if (ViewContext.RouteData.Values["Action"] == "Blob" && i + 1 == dirs.Length)
                {
                    @dirs[i]
                }
                else
                {
                    @Html.ActionLink(dirs[i], "Tree", new { path = currentPath, id = ViewBag.ID })                    
                }

                if (i + 1 != dirs.Length)
                {
                        <text>/</text>
                }
            }
        }
    </p>
}